<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>04-v-bind动态绑定style(对象语法).html</title>
</head>

<body>
  <div id='app' v-cloak>
    <!-- <h2 :style="{key(属性名): value(属性值)}">{{message}}</h2> -->
    <h2 :style="{fontSize: size+'px',backgroundColor:green}">{{message}}</h2>
    <h2 :style="getStyle()">{{message}}</h2>
  </div>
  <script src='../js/vue.js'></script>
  <script>
    const app = new Vue({
      el: '#app',
      data: {
        message: 'hello Vue',
        size: 100,
        green: 'green'
      },
      methods: {
        getStyle: function() {
          return {
            fontSize: this.size + 'px',
            backgroundColor: this.green
          };
        }
      }
    })
  </script>
  <style>
    [v-cloak] {
      display: none;
    }
  </style>
</body>

</html>